import time, os
from time import sleep
import subprocess
from common.loger_handler import mylog
from page_element.key import PageKey


class page_set2(PageKey):
    """智能电池"""

    def set_002_001(self):
        """飞行器电池，遥控器电池"""
        self.iv_zorroRealcontrol_set.click()
        self.set_2.click()
        VAU_battery = self.driver(resourceId="com.gdu.pro2:id/tv_batteryPercent").get_text()
        self.driver(resourceId="com.gdu.pro2:id/rc_battery").click()
        rc_battery = self.driver(resourceId="com.gdu.pro2:id/tv_batteryPercent").get_text()
        self.driver.press("back")
        VAU_battery2 = self.driver(resourceId="com.gdu.pro2:id/tv_aircraft").get_text()

        output = subprocess.check_output(['adb', 'shell', 'dumpsys', 'battery'], universal_newlines=True)
        for line in output.split('\n'):
            if 'level' in line:
                parts = line.split()
                for part in parts:
                    if part.isdigit():
                        rc_battery2 = part
        mylog.info(F"----------{VAU_battery}-----{VAU_battery2}----{rc_battery}----{rc_battery2}%")

    def set_002_002(self):
        """低电量报警值，超低电量报警值"""
        self.iv_zorroRealcontrol_set.click()
        self.set_2.click()





